<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="icon" href="">
</head>
<body>
<textarea style="width:800px" rows="30" id="json">
{"frames":{"1/000960.png":{"frame":{"h":113,"idx":0,"w":104,"x":0,"y":0},"sourceSize":{"h":113,"w":104},"spriteSourceSize":{"x":-18,"y":-67}},"1/000963.png":{"frame":{"h":114,"idx":1,"w":104,"x":104,"y":0},"sourceSize":{"h":114,"w":104},"spriteSourceSize":{"x":-18,"y":-67}},"1/000962.png":{"frame":{"h":114,"idx":2,"w":104,"x":0,"y":114},"sourceSize":{"h":114,"w":104},"spriteSourceSize":{"x":-18,"y":-67}},"1/000961.png":{"frame":{"h":115,"idx":3,"w":104,"x":104,"y":114},"sourceSize":{"h":115,"w":104},"spriteSourceSize":{"x":-18,"y":-67}}},"meta":{"image":"monster_0_0.png","prefix":""}}
</textarea>
<br>
<label for="fnode">节点</label>
  <input type="text" style="width:300px" id="fnode" name="fnode" value="spriteSourceSize.y"><br><br>
  <label for="fvalue">值</label>
  <input type="text" style="width:300px" id="fvalue" name="fvalue" value="+67"><br><br>
<button onclick="doclick()" style="width:300px">修改</button>
</body>
<script  type="text/javascript">
	var nodes = [];
	var fvalue = 0;
    function doclick() {
		var json = document.getElementById("json").value;
		var fnode = document.getElementById("fnode").value;
		nodes = fnode.split(".");
		fvalue = parseInt(document.getElementById("fvalue").value);
		var obj = JSON.parse(json);
		var tempObj = obj.frames;

		for (var k in tempObj) {
			tempObj[k] = doclick2(tempObj[k], 0);
		}
		obj.frames = tempObj;
		document.getElementById("json").value = JSON.stringify(obj);
    }
    
    function doclick2(obj, nodeIndex) {
		for (var n = nodeIndex; n < nodes.length; n++) {
			if(obj[nodes[n]]){
				if(n == nodes.length - 1){
					obj[nodes[n]] += fvalue;
				}else{
					obj[nodes[n]] = doclick2(obj[nodes[n]], n + 1);
				}
			}
		}
		return obj;
    }
</script>
</html>